#include "Light.h"


//light coord
Matrix DirectionalLight::LookAt(const Vec4f& upAxis)
{
	Vec4f lookDir = dir;
	lookDir.Normalize();

	Vec4f rightDir = Vec4f::Cross(upAxis, lookDir);
	rightDir.Normalize();

	Vec4f upDir = Vec4f::Cross(lookDir, rightDir);
	upDir.Normalize();

	Matrix m;
	m.mat[0][0] = rightDir.x; m.mat[0][1] = rightDir.y; m.mat[0][2] = rightDir.z; m.mat[0][3] = -pos.x;
	m.mat[1][0] = upDir.x; m.mat[1][1] = upDir.y; m.mat[1][2] = upDir.z; m.mat[1][3] = -pos.y;
	m.mat[2][0] = lookDir.x; m.mat[2][1] = lookDir.y; m.mat[2][2] = lookDir.z; m.mat[2][3] = -pos.z;
	m.mat[3][0] = 0; m.mat[3][1] = 0; m.mat[3][2] =0; m.mat[3][3] =1;
	return m;
}
